package com.pandora.credit.exception;

import com.pandora.credit.enums.ExceptionEnum;

import java.util.HashMap;
import java.util.Map;

/**
 * @author developer
 */
public abstract class AbstractBusinessException extends RuntimeException {
    private int code;
    private String msg;

    protected AbstractBusinessException(ExceptionEnum type) {
        code = type.getCode();
        msg = type.getMsg();
    }

    protected AbstractBusinessException(ExceptionEnum type, String msg) {
        code = type.getCode();
        this.msg = msg;
    }

    public Map<String, Object> getResponse() {
        Map<String, Object> ret = new HashMap<>(2);
        ret.put("err_code", code);
        ret.put("err_msg", msg);
        return ret;
    }
}
